﻿/*------------------------------------------------------------------------

PRIMITIVERD.HPP v1.0.2


Copyright 楊志賢 CxxlMan, 2013 - 2014
All Rights Reserved

------------------------------------------------------------------------*/

#if !defined(__TPRIMITIVERD_HPP_Cxxl3D)
#define __TPRIMITIVERD_HPP_Cxxl3D

#include <Sys\RENDERUNIT.HPP>
#include <Sys\RenderUnit\SYSDDCLASSID.HPP>
// #include <Sys\RenderUnit\SysRenderDatagram\VERTEXRD.HPP>

namespace Cxxl3D
{



// 以 IVertexRD 為頂點的 TrianglesStrip 3D 模形
class ITrianglesStripRD:public IRenderDatagram
{
  // 這裡須傳回 IRenderDatagram 的 "實作介面"，即被 cxxlCM_GetElement() 叫用的 InterfaceID
  CxxlMan::UNICODE_String cxxlFASTCALL GetRenderDatagramID() const
  {
    return ITrianglesStrip_ClassID;
  }

  // 傳回 IRenderDatagram 的 "實作介面"
  virtual void *cxxlFASTCALL GetDefaultInterface()
  {
    return this;
  }

protected:
  // 儲存容器藉此取得要永續存取的屬性資料
  // 延伸類別須以 virtual 的形式覆寫
  // 並且須呼叫上層類別的此函數
  virtual bool cxxlFASTCALL Ref(CxxlMan::Filter *F)
  {
    if(F != NULL && IRenderDatagram::Ref(F))
      return true;
    else
      return false;
  }


  // Constructor
  ITrianglesStripRD()
    :cxxlObject(CxxlMan::Spirit_Easy),
    CxxlMan::cxxlPreserve2(ITrianglesStrip_ClassID) // 在建構時指定 ClassID
  {
  }

  // Destructor
  ~ITrianglesStripRD()
  {
  }

public:

 // virtual void cxxlFASTCALL SetVertexStrip(const CxxlMan::Smart_Ptr<IVertex> &IVertexStripRD_Arg) = 0;
 // virtual CxxlMan::Smart_Ptr<IVertex> cxxlFASTCALL GetVertexStrip() const = 0;

  // 建立 ITrianglesStripRD 物件，失敗傳回 NULL
  static CxxlMan::Smart_Ptr<ITrianglesStripRD> cxxlFASTCALL Create()
  {
    return CxxlMan::Preserve2_Cast<ITrianglesStripRD>( CxxlMan::cxxlCM_GetElement(ITrianglesStrip_ClassID, IRenderDatagram_Group) );
  }

  // 從永存資料產生 ITrianglesStripRD 物件
  // 失敗傳回 NULL
  static CxxlMan::Smart_Ptr<ITrianglesStripRD> cxxlFASTCALL Create(const CxxlMan::UNICODE_String &BackupName, const CxxlMan::Smart_Ptr<CxxlMan::IcxxlStorage> &IcxxlStorage_Arg)
  {
    CxxlMan::Smart_Ptr<cxxlPreserve2> cxxlPreserve2_Ptr(NULL);
    CxxlMan::REGENERARETURN_TYPE rt = cxxlCM_Regenera(cxxlPreserve2_Ptr, BackupName, IcxxlStorage_Arg, true);

    if(rt == CxxlMan::Regenera_Success)
      return CxxlMan::Smart_Cast<ITrianglesStripRD>(cxxlPreserve2_Ptr);
    else
      return NULL;
  }


  friend class CxxlMan::IcxxlStorage;          // Preserve2 元件須加上這個
  friend class CxxlMan::Smart_Ptr<ITrianglesStripRD>;  // Preserve2 元件須加上這個
};


/*****************************************************************************/


// 以 IVertexRD 為頂點的 TrianglesList 3D 模形
class ITrianglesListRD:public IRenderDatagram
{
  // 這裡須傳回 IRenderDatagram 的 "實作介面"，即被 cxxlCM_GetElement() 叫用的 InterfaceID
  CxxlMan::UNICODE_String cxxlFASTCALL GetRenderDatagramID() const
  {
    return ITrianglesList_ClassID;
  }

  // 傳回 IRenderDatagram 的 "實作介面"
  virtual void *cxxlFASTCALL GetDefaultInterface()
  {
    return this;
  }

protected:
  // 儲存容器藉此取得要永續存取的屬性資料
  // 延伸類別須以 virtual 的形式覆寫
  // 並且須呼叫上層類別的此函數
  virtual bool cxxlFASTCALL Ref(CxxlMan::Filter *F)
  {
    if(F != NULL && IRenderDatagram::Ref(F))
      return true;
    else
      return false;
  }


  // Constructor
  ITrianglesListRD()
    :cxxlObject(CxxlMan::Spirit_Easy),
    CxxlMan::cxxlPreserve2(ITrianglesList_ClassID) // 在建構時指定 ClassID
  {
  }

  // Destructor
  ~ITrianglesListRD()
  {
  }

public:

  // virtual void cxxlFASTCALL SetVertexList(const CxxlMan::Smart_Ptr<IVertex> &IVertexListRD_Arg) = 0;
  // virtual CxxlMan::Smart_Ptr<IVertex> cxxlFASTCALL GetVertexList() const = 0;

  // 建立 ITrianglesListRD 物件，失敗傳回 NULL
  static CxxlMan::Smart_Ptr<ITrianglesListRD> cxxlFASTCALL Create()
  {
    return CxxlMan::Preserve2_Cast<ITrianglesListRD>( CxxlMan::cxxlCM_GetElement(ITrianglesList_ClassID, IRenderDatagram_Group) );
  }

  // 從永存資料產生 ITrianglesListRD 物件
  // 失敗傳回 NULL
  static CxxlMan::Smart_Ptr<ITrianglesListRD> cxxlFASTCALL Create(const CxxlMan::UNICODE_String &BackupName, const CxxlMan::Smart_Ptr<CxxlMan::IcxxlStorage> &IcxxlStorage_Arg)
  {
    CxxlMan::Smart_Ptr<cxxlPreserve2> cxxlPreserve2_Ptr(NULL);
    CxxlMan::REGENERARETURN_TYPE rt = cxxlCM_Regenera(cxxlPreserve2_Ptr, BackupName, IcxxlStorage_Arg, true);

    if(rt == CxxlMan::Regenera_Success)
      return CxxlMan::Smart_Cast<ITrianglesListRD>(cxxlPreserve2_Ptr);
    else
      return NULL;
  }


  friend class CxxlMan::IcxxlStorage;          // Preserve2 元件須加上這個
  friend class CxxlMan::Smart_Ptr<ITrianglesListRD>;  // Preserve2 元件須加上這個
};











}   /* namespace Cxxl3D */
#endif
